package com.wilmer.userSchedule.service.impl;

import java.util.List;

import com.wilmer.common.annotation.DataScope;
import com.wilmer.common.utils.DateUtils;
import com.wilmer.common.utils.SecurityUtils;
import com.wilmer.userSchedule.domain.vo.editVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wilmer.userSchedule.mapper.SysUserScheduleMapper;
import com.wilmer.userSchedule.domain.SysUserSchedule;
import com.wilmer.userSchedule.service.ISysUserScheduleService;

/**
 * 用户日程Service业务层处理
 * 
 * @author hans
 * @date 2024-04-11
 */
@Service
public class SysUserScheduleServiceImpl implements ISysUserScheduleService 
{
    @Autowired
    private SysUserScheduleMapper sysUserScheduleMapper;

    /**
     * 查询用户日程
     * 
     * @param scheduleId 用户日程主键
     * @return 用户日程
     */
    @Override
    public SysUserSchedule selectSysUserScheduleByScheduleId(Long scheduleId)
    {
        return sysUserScheduleMapper.selectSysUserScheduleByScheduleId(scheduleId);
    }

    /**
     * 查询用户日程列表
     * 
     * @param sysUserSchedule 用户日程
     * @return 用户日程
     */
    @DataScope(deptAlias = "d", userAlias = "u")
    @Override
    public List<SysUserSchedule> selectSysUserScheduleList(SysUserSchedule sysUserSchedule)
    {
        return sysUserScheduleMapper.selectSysUserScheduleList(sysUserSchedule);
    }

    @DataScope(deptAlias = "d", userAlias = "u")
    @Override
    public List<SysUserSchedule> selectScheduleList(SysUserSchedule sysUserSchedule) {
        sysUserSchedule.setUserId(SecurityUtils.getUserId());
        return sysUserScheduleMapper.selectSysUserScheduleList(sysUserSchedule);
    }

    /**
     * 新增用户日程
     * 
     * @param sysUserSchedule 用户日程
     * @return 结果
     */
    @Override
    public int insertSysUserSchedule(SysUserSchedule sysUserSchedule)
    {
        sysUserSchedule.setCreateTime(DateUtils.getNowDate());
        return sysUserScheduleMapper.insertSysUserSchedule(sysUserSchedule);
    }

    /**
     * 修改用户日程
     * 
     * @param sysUserSchedule 用户日程
     * @return 结果
     */
    @Override
    public int updateSysUserSchedule(SysUserSchedule sysUserSchedule)
    {
        sysUserSchedule.setUpdateTime(DateUtils.getNowDate());
        return sysUserScheduleMapper.updateSysUserSchedule(sysUserSchedule);
    }

    /**
     * 批量删除用户日程
     * 
     * @param scheduleIds 需要删除的用户日程主键
     * @return 结果
     */
    @Override
    public int deleteSysUserScheduleByScheduleIds(Long[] scheduleIds)
    {
        return sysUserScheduleMapper.deleteSysUserScheduleByScheduleIds(scheduleIds);
    }

    /**
     * 删除用户日程信息
     * 
     * @param scheduleId 用户日程主键
     * @return 结果
     */
    @Override
    public int deleteSysUserScheduleByScheduleId(Long scheduleId)
    {
        return sysUserScheduleMapper.deleteSysUserScheduleByScheduleId(scheduleId);
    }

    @Override
    public int doEdit(editVo editVo) {
        return sysUserScheduleMapper.doEdit(editVo);
    }
}
